<?php

namespace Biz\model\activity;

class SearchFeedback extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_shop';

    const _CONFIG_SELECT_ = 'db_activity';

    const _DATABASE_ = 'shop_activity';

    const _TABLE_NAME = 'search_feedback';


    public static function findFeedback($uid, $input_requestId, $input_query)
    {
        $where = [
            'uid' => $uid,
            'input_requestId' => $input_requestId,
            'input_query' => $input_query,
        ];

        return self::count($where) > 0;
    }

    public static function addFeedback($uid, $feedback_score, $feedback_reason, $feedback_other, $input_requestId, $input_query)
    {
        $data = [
            'uid' => $uid,
            'feedback_score' => $feedback_score,
            'feedback_reason' => $feedback_reason,
            'feedback_other' => $feedback_other,
            'input_requestId' => $input_requestId,
            'input_query' => $input_query,
            'addtime' => date("Y-m-d H:i:s"),
        ];
        if (self::insert($data)->rowcount()) {
            return self::id();
        } else {
            return false;
        }
    }

    public static function getListByWhere($where)
    {

       return self::select("*"  , $where);
    }
}